package cn.copera.dyy.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import cn.copera.dyy.common.service.BaseService;
import cn.copera.dyy.dao.UserShopDao;
import cn.copera.dyy.entity.UserShop;

/**
 * 店铺用户Service
 * 
 */
@Service
@Transactional(readOnly = true)
public class UserShopService extends BaseService {

	@Autowired
	private UserShopDao shopDao;
	

	
	@Transactional(readOnly = false)
	public void save(UserShop shop) {
		shopDao.clear();
		shopDao.save(shop);
	}
	
	public UserShop findUserShop(String shopId){
		
		return shopDao.findExistEntity(new UserShop(), "shop.id = '"+shopId+"'");
	}
	
	public UserShop findUserShopByOpenid(String shopId,String openid){
		return shopDao.findExistEntity(new UserShop(), "shop.id = '"+shopId+"' and openid='"+openid+"'");
	}
	
	@Transactional(readOnly = false)
	public void update(UserShop shop){
		shopDao.saveEntity(shop);
	}
}
